package com.example.novelsys.dao;

import com.example.novelsys.entity.Novel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;


import java.util.List;


//小说 的持久CRUD
@Mapper
public interface NovelDao {


	public List<Novel> queryNovelByType(@Param("type") Integer type);

	//根据书名或 作者 模糊查询小说
	@Select("select * from novel where title like concat('%',#{searchKey},'%')  or authorName like concat('%',#{searchKey},'%')  ")
	public List<Novel> queryLike(String searchKey);

	//根据  cateId分类查询 排序方式，文件大小等情况下的 小说信息
	public List<Novel> queryByCateId(@Param("cateId") Integer cateId,@Param("orderIndex")Integer orderIndex,@Param("fileIndex") Integer fileIndex);


	//根据novelId查询发表的小说及其章节内容
	//通过可以支持下载
	public Novel queryBykey(Integer novelId);

	//根据novelId 单表查询 novel表
	@Select("select * from novel where novelId=#{novelId} ")
	public Novel queryByNovelId(Integer novelId);


	//根据用户id查询发表的小说
	@Select("select * from novel where SendID=#{userId}")
	public List<Novel> queryByID(Long userId);

}
